//
//  OnionCertificationCell.m
//  OnionHome
//
//  Created by fengjie on 2019/10/2.
//  Copyright © 2019 FengJie. All rights reserved.
//

#import "OnionCertificationCell.h"


@interface OnionCertificationCell ()
/**<#属性#>*/
@property (nonatomic,strong)UILabel*topLabel;
/**<#属性#>*/
@property (nonatomic,strong)UILabel*bomLabel;
@end

@implementation OnionCertificationCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self createUI];
    }
    return self;
}
-(void)createUI{
    
    UIImageView * moreImage = [[UIImageView alloc] initWithImage:IMAGE_NAMED(@"more")];
    
    [self addSubview:self.topLabel];
    [self addSubview:self.bomLabel];
    [self addSubview:moreImage];
    
    [self.topLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_equalTo(16);
    }];
    [self.bomLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.bottom.mas_equalTo(-16);
        make.top.mas_equalTo(self.topLabel.mas_bottom).offset(8);
    }];
    
    [moreImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.right.mas_equalTo(-16);
    }];
}
-(void)setDic:(NSDictionary *)dic{
    _dic = dic;
    self.topLabel.text = dic[@"topName"];
    self.bomLabel.text = dic[@"bomName"];
}
-(UILabel*)topLabel{
    if(!_topLabel){
        _topLabel=[UILabel new];
        _topLabel.textColor = UIColorFromRGB(0x273323);
        _topLabel.font = SYSTEMFONT(18);
    }
    return _topLabel;
}
-(UILabel*)bomLabel{
    if(!_bomLabel){
        _bomLabel=[UILabel new];
        _bomLabel.textColor = UIColorFromRGB(0x8E8E8E);
        _bomLabel.font = SYSTEMFONT(12);
    }
    return _bomLabel;
}

@end


@interface OnionCertificationUserCell ()
/**<#属性#>*/
@property (nonatomic,strong)UserIconAndNameView*userView;
@end

@implementation OnionCertificationUserCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self addSubview:self.userView];
        
        [self.userView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.bottom.right.mas_equalTo(0);
        }];
    }
    return self;
}
-(UserIconAndNameView*)userView{
    if(!_userView){
        _userView=[[UserIconAndNameView alloc] initWithFrame:CGRectZero];
        _userView.deleButton.hidden = YES;
        _userView.dynamicData.text = @"美食领域达人";
    }
    return _userView;
}
@end


@interface OnionCertificationProgressCell ()
/**<#属性#>*/
@property (nonatomic,strong)UIButton*oneBtn;
/**<#属性#>*/
@property (nonatomic,strong)UIButton*oneLine;
/**<#属性#>*/
@property (nonatomic,strong)UIButton*twoBtn;
/**<#属性#>*/
@property (nonatomic,strong)UIButton*twoLine;
/**<#属性#>*/
@property (nonatomic,strong)UIButton*thereBtn;
/**<#属性#>*/
@property (nonatomic,strong)UIButton*thereLine;
/**<#属性#>*/
@property (nonatomic,strong)UIButton*fourBtn;
@end

@implementation OnionCertificationProgressCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self createUI];
    }
    return self;
}

/**返回到指定控制器*/
-(void)popViewController:(Class )toVClass{
    BOOL isAre = NO;
    for (UIViewController *controller in [self getCurrentViewController].navigationController.viewControllers) {
        if ([controller isKindOfClass:toVClass]) {
            isAre = YES;
            [[self getCurrentViewController].navigationController popToViewController:controller animated:YES];
        }
    }
    if (!isAre) {
        [[self getCurrentViewController].navigationController popToRootViewControllerAnimated:YES];
    }
}

-(void)createUI{
    UIView * view = UIView.new;
    ViewBorderRadius(view, 3, 0.5, UIColorFromRGB(0xE9EEE7));
    [self addSubview:view];
    
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_equalTo(16);
        make.right.mas_equalTo(-16);
        make.bottom.mas_equalTo(-30);
    }];
    
    UILabel * titleLabel = UILabel.new;
    titleLabel.textColor = UIColorFromRGB(0x485345);
    titleLabel.font = SYSTEMFONT(18);
    titleLabel.text = @"请30天内完成任务，否则将取消认证";
    
    UILabel * contenxLabel = UILabel.new;
    contenxLabel.textColor = UIColorFromRGB(0x8E8E8E);
    contenxLabel.font = SYSTEMFONT(14);
    contenxLabel.text = @"连续4条发布优质内容，即通过考核期";
    
    UIButton * commitBnt = [UIButton buttonWithType:UIButtonTypeCustom];
    [commitBnt setTitle:@"去完成" forState:UIControlStateNormal];
    [commitBnt setBackgroundImage:IMAGE_NAMED(@"guanzhu_bg") forState:UIControlStateNormal];
    commitBnt.titleLabel.font = SYSTEMFONT(14);
    kWeakSelf(weakSelf);
    [commitBnt addActionHandler:^{
        [weakSelf popViewController:[PersonalHomePageBasseController class]];
    }];
    
    [view addSubview:titleLabel];
    [view addSubview:contenxLabel];
    [view addSubview:self.oneBtn];
    [view addSubview:self.oneLine];
    [view addSubview:self.twoBtn];
    [view addSubview:self.twoLine];
    [view addSubview:self.thereBtn];
    [view addSubview:self.thereLine];
    [view addSubview:self.fourBtn];
    [view addSubview:commitBnt];
    
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(30);
    }];
    [contenxLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       make.centerX.mas_equalTo(0);
       make.top.mas_equalTo(titleLabel.mas_bottom).offset(8);
    }];
    [self.oneBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(25);
        make.top.mas_equalTo(titleLabel.mas_bottom).offset(40);
        make.width.height.mas_equalTo(26);
    }];
    CGFloat width = (KScreenWidth - 50 - 26*4 - 32)/3;
    [self.oneLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.oneBtn);
        make.left.mas_equalTo(self.oneBtn.mas_right);
        make.width.mas_equalTo(width);
        make.height.mas_equalTo(2);
    }];
    
    [self.twoBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.oneLine.mas_right);
        make.centerY.mas_equalTo(self.oneBtn);
        make.width.height.mas_equalTo(26);
    }];
    [self.twoLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.oneBtn);
        make.left.mas_equalTo(self.twoBtn.mas_right);
        make.width.mas_equalTo(width);
        make.height.mas_equalTo(2);
    }];
    [self.thereBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.twoLine.mas_right);
        make.centerY.mas_equalTo(self.oneBtn);
        make.width.height.mas_equalTo(26);
    }];
    [self.thereLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.oneBtn);
        make.left.mas_equalTo(self.thereBtn.mas_right);
        make.width.mas_equalTo(width);
        make.height.mas_equalTo(2);
    }];
    [self.fourBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.thereLine.mas_right);
        make.centerY.mas_equalTo(self.oneBtn);
        make.width.height.mas_equalTo(26);
    }];
    [commitBnt mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(self.oneBtn.mas_bottom).offset(20);
        make.bottom.mas_equalTo(-10);
    }];
}
-(UIButton*)oneBtn{
    if(!_oneBtn){
        _oneBtn=[UIButton new];
        [_oneBtn setTitle:@"1" forState:UIControlStateNormal];
        [_oneBtn setBackgroundImage:IMAGE_NAMED(@"guanzhu_bg") forState:UIControlStateSelected];
        [_oneBtn setBackgroundImage:[UIImage createImageWithColor:UIColorFromRGB(0xE7E7E7)] forState:UIControlStateNormal];
        _oneBtn.selected = YES;
        _oneBtn.titleLabel.font = SYSTEMFONT(14);

        ViewRadius(_oneBtn, 13);
    }
    return _oneBtn;
}

-(UIButton*)twoBtn{
    if(!_twoBtn){
        _twoBtn=[UIButton new];
        [_twoBtn setTitle:@"2" forState:UIControlStateNormal];
        [_twoBtn setBackgroundImage:IMAGE_NAMED(@"guanzhu_bg") forState:UIControlStateSelected];
        [_twoBtn setBackgroundImage:[UIImage createImageWithColor:UIColorFromRGB(0xE7E7E7)] forState:UIControlStateNormal];
        _twoBtn.titleLabel.font = SYSTEMFONT(14);

        ViewRadius(_twoBtn, 13);
    }
    return _twoBtn;
}

-(UIButton*)thereBtn{
    if(!_thereBtn){
        _thereBtn=[UIButton new];
        [_thereBtn setTitle:@"3" forState:UIControlStateNormal];
        [_thereBtn setBackgroundImage:IMAGE_NAMED(@"guanzhu_bg") forState:UIControlStateSelected];
        [_thereBtn setBackgroundImage:[UIImage createImageWithColor:UIColorFromRGB(0xE7E7E7)] forState:UIControlStateNormal];
        _thereBtn.titleLabel.font = SYSTEMFONT(14);

        ViewRadius(_thereBtn, 13);
    }
    return _thereBtn;
}

-(UIButton*)fourBtn{
    if(!_fourBtn){
        _fourBtn=[UIButton new];
        [_fourBtn setTitle:@"4" forState:UIControlStateNormal];
        [_fourBtn setBackgroundImage:IMAGE_NAMED(@"guanzhu_bg") forState:UIControlStateSelected];
        [_fourBtn setBackgroundImage:[UIImage createImageWithColor:UIColorFromRGB(0xE7E7E7)] forState:UIControlStateNormal];
        _fourBtn.titleLabel.font = SYSTEMFONT(14);

        ViewRadius(_fourBtn, 13);
    }
    return _fourBtn;
}
-(UIButton*)oneLine{
    if(!_oneLine){
        _oneLine=[UIButton new];
        [_oneLine setBackgroundImage:IMAGE_NAMED(@"guanzhu_bg") forState:UIControlStateSelected];
        [_oneLine setBackgroundImage:[UIImage createImageWithColor:UIColorFromRGB(0xE7E7E7)] forState:UIControlStateNormal];
    }
    return _oneLine;
}

-(UIButton*)twoLine{
    if(!_twoLine){
        _twoLine=[UIButton new];
        [_twoLine setBackgroundImage:IMAGE_NAMED(@"guanzhu_bg") forState:UIControlStateSelected];
        [_twoLine setBackgroundImage:[UIImage createImageWithColor:UIColorFromRGB(0xE7E7E7)] forState:UIControlStateNormal];
    }
    return _twoLine;
}

-(UIButton*)thereLine{
    if(!_thereLine){
        _thereLine=[UIButton new];
        [_thereLine setBackgroundImage:IMAGE_NAMED(@"guanzhu_bg") forState:UIControlStateSelected];
        [_thereLine setBackgroundImage:[UIImage createImageWithColor:UIColorFromRGB(0xE7E7E7)] forState:UIControlStateNormal];
    }
    return _thereLine;
}
@end
